home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / gfx / show / MPEGIntuition.lha / Agnen.e < prev    next >
Text File  |  1995-09-04  |  5KB  |  160 lines

  1. /*
  2. ** Agnen ver 0.9 by Mahdi/Sauron and Sihaja (:)
  3. ** 
  4. ** This program send by Signal(0 CTRL_C to task called 'Background CLI'
  5. ** Thats mean to all progrmas run by run or execute functions
  6. */
  7.  
  8. OPT OSVERSION=37
  9.  
  10. MODULE 'gadtools','libraries/gadtools','intuition/intuition',
  11.        'intuition/screens', 'intuition/gadgetclass', 'graphics/text',
  12.        'amigalib/tasks','dos/dos'
  13.  
  14. ENUM NONE,NOCONTEXT,NOGADGET,NOWB,NOVISUAL,OPENGT,NOWINDOW,NOMENUS
  15.  
  16. DEF     project0wnd:PTR TO window,
  17.         project0glist,
  18.         terButton=NIL:PTR TO gadget,
  19.         decButton=NIL:PTR TO gadget,
  20.         hexButton=NIL:PTR TO gadget,
  21.         infos:PTR TO gadget,
  22.         scr:PTR TO screen,
  23.         visual=NIL,
  24.        
  25. offx,offy,tattr,process,processOld,processDEC[10]:STRING,processHEX[10]:STRING
  26.  
  27. PROC setupscreen()
  28.   IF (gadtoolsbase:=OpenLibrary('gadtools.library',37))=NIL THEN RETURN OPENGT
  29.   IF (scr:=LockPubScreen('Workbench'))=NIL THEN RETURN NOWB
  30.   IF (visual:=GetVisualInfoA(scr,NIL))=NIL THEN RETURN NOVISUAL
  31.   offy:=scr.wbortop+Int(scr.rastport+58)-10
  32.   tattr:=['topaz.font',8,0,0]:textattr
  33. ENDPROC
  34.  
  35. CHAR '$VER: Agnen v1.0 by MAHDI/SAURON (c) 1995',0
  36.  
  37. PROC closedownscreen()
  38.   IF visual THEN FreeVisualInfo(visual)
  39.   IF scr THEN UnlockPubScreen(NIL,scr)
  40.   IF gadtoolsbase THEN CloseLibrary(gadtoolsbase)
  41. ENDPROC
  42.  
  43. PROC openproject0window()
  44.   DEF g:PTR TO gadget
  45.   IF (g:=CreateContext({project0glist}))=NIL THEN RETURN NOCONTEXT
  46.   IF (g:=terButton:=CreateGadgetA(BUTTON_KIND,g,
  47.     [offx+15,offy+16,105,27,'Terminate',tattr,0,16,visual,0]:newgadget,
  48.     [NIL]))=NIL THEN RETURN NOGADGET
  49.   IF (g:=decButton:=CreateGadgetA(TEXT_KIND,g,
  50.     [offx+166,offy+16,92,11,'DEC',tattr,1,1,visual,0]:newgadget,
  51.     [GTTX_TEXT,'   NO TASK',
  52.      GTTX_BORDER,1,
  53.      NIL]))=NIL THEN RETURN NOGADGET
  54.   IF (g:=hexButton:=CreateGadgetA(TEXT_KIND,g,
  55.     [offx+166,offy+32,92,11,'HEX',tattr,2,1,visual,0]:newgadget,
  56.     [GTTX_TEXT,'   NO TASK',
  57.      GTTX_BORDER,1,
  58.      NIL]))=NIL THEN RETURN NOGADGET
  59.   IF (project0wnd:=OpenWindowTagList(NIL,
  60.     [WA_LEFT,175,
  61.      WA_TOP,44,
  62.      WA_WIDTH,offx+275,
  63.      WA_HEIGHT,offy+50,
  64.      WA_IDCMP,$24C077E,
  65.      WA_FLAGS,$100E,
  66.      WA_TITLE,'Agnen - task terminator',
  67.      WA_SCREENTITLE,'Agnen by Mahdi/Sauron',
  68.      WA_CUSTOMSCREEN,scr,
  69.      WA_MINWIDTH,67,
  70.      WA_MINHEIGHT,21,
  71.      WA_MAXWIDTH,$2D2,
  72.      WA_MAXHEIGHT,283,
  73.      WA_AUTOADJUST,1,
  74.      WA_AUTOADJUST,1,
  75.      WA_GADGETS,project0glist,
  76.      NIL]))=NIL THEN RETURN NOWINDOW
  77.   Gt_RefreshWindow(project0wnd,NIL)
  78. ENDPROC
  79.  
  80. PROC closeproject0window()
  81.   IF project0wnd THEN CloseWindow(project0wnd)
  82.   IF project0glist THEN FreeGadgets(project0glist)
  83. ENDPROC
  84.  
  85. PROC wait4message(win:PTR TO window)
  86.   DEF mes:PTR TO intuimessage,type
  87.   REPEAT
  88.     type:=0
  89.     IF process:=FindTask('Background CLI')
  90.         IF process<>processOld
  91.             processOld:=process
  92.             StringF(processDEC,'   \d',process)
  93.             StringF(processHEX,'    \h',process)
  94.                    Gt_SetGadgetAttrsA (decButton, project0wnd, NIL,
  95.                    [GTTX_TEXT,processDEC,NIL])
  96.                    Gt_SetGadgetAttrsA (hexButton, project0wnd, NIL,
  97.                    [GTTX_TEXT,processHEX,NIL])
  98.         ELSEIF process=0
  99.                    Gt_SetGadgetAttrsA (decButton, project0wnd, NIL,
  100.                    [GTTX_TEXT,'  NO TASK',NIL])
  101.                    Gt_SetGadgetAttrsA (hexButton, project0wnd, NIL,
  102.                    [GTTX_TEXT,'  NO TASK',NIL])
  103.         ENDIF
  104.     ELSE
  105.     ENDIF
  106.     IF mes:=Gt_GetIMsg(win.userport)
  107.       type:=mes.class
  108.       IF type=IDCMP_MENUPICK
  109.         infos:=mes.code
  110.       ELSEIF type=IDCMP_GADGETUP
  111.         infos:=mes.iaddress
  112.         infos.gadgetid:=mes.code
  113.       ELSEIF type=IDCMP_REFRESHWINDOW
  114.         Gt_BeginRefresh(win)
  115.         Gt_EndRefresh(win,TRUE)
  116.         type:=0
  117.       ELSEIF type<>IDCMP_CLOSEWINDOW  /* remove these if you like */
  118.         type:=0
  119.       ENDIF
  120.       Gt_ReplyIMsg(mes)
  121.     ELSE
  122.       WaitPort(win.userport)
  123.     ENDIF
  124.   UNTIL type
  125. ENDPROC type
  126.  
  127. PROC reporterr(er)
  128.   DEF erlist:PTR TO LONG
  129.   IF er
  130.     erlist:=['get context','create gadget','lock wb','get visual infos',
  131.       'open "gadtools.library" v37+','open window','create menus']
  132.     EasyRequestArgs(0,[20,0,0,'Could not \s!','ok'],0,[erlist[er-1]])
  133.   ENDIF
  134. ENDPROC er
  135.  
  136. PROC main()
  137.   DEF messageClass
  138.   IF reporterr(setupscreen())=0
  139.     reporterr(openproject0window())
  140.     REPEAT
  141.        messageClass:=wait4message(project0wnd)
  142.        SELECT messageClass
  143.          CASE IDCMP_GADGETUP
  144.            SELECT infos  /* pointer TO gadget */
  145.               CASE terButton
  146.                   Signal(process,SIGBREAKF_CTRL_C)
  147.                    Gt_SetGadgetAttrsA (decButton, project0wnd, NIL,
  148.                    [GTTX_TEXT,'TERMINATED',NIL])
  149.                    Gt_SetGadgetAttrsA (hexButton, project0wnd, NIL,
  150.                    [GTTX_TEXT,'TERMINATED',NIL])
  151.            ENDSELECT
  152.        ENDSELECT
  153.     UNTIL messageClass=IDCMP_CLOSEWINDOW
  154.     closeproject0window()
  155.     IF CtrlC() THEN BRA x
  156.   ENDIF
  157.   x: closedownscreen()
  158. ENDPROC
  159.  
  160.